package fhp.hlhj.giantfold.activity.user

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.BaseActivity
import fhp.hlhj.giantfold.Contents
import fhp.hlhj.giantfold.R
import fhp.hlhj.giantfold.interfaces.IBindAli
import fhp.hlhj.giantfold.javaBean.BaseBean
import fhp.hlhj.giantfold.presenter.BindAliPresenter
import fhp.hlhj.giantfold.utils.MyUtils
import kotlinx.android.synthetic.main.activity_bind_ali_aty.*

class BindAliAty : BaseActivity(), IBindAli {
    override fun getContentId(): Int = R.layout.activity_bind_ali_aty
    private lateinit var bindAliPresenter:BindAliPresenter
    override fun initView() {

        bindAliPresenter= BindAliPresenter(this)

    }

    override fun initListener() {
        btExit.setOnClickListener {
            finish()
        }

        btCommit.setOnClickListener {
            if (etAliUserName.text.isNotEmpty() &&etTrueName.text.isNotEmpty()){
                val params = HttpParams()
                params.put("alipay_account",etAliUserName.text.toString())
                params.put("alipay_user_name",etTrueName.text.toString())
                params.put("user_id",Contents.userId)
                bindAliPresenter.bindAli(params)
            }
        }
    }

    override fun showLoading() {
        loadingDialog.show()
    }

    override fun bindAli(baseBean: BaseBean) {
        loadingDialog.dismiss()
        if (baseBean.code==200){
            MyUtils.toast("绑定成功")

            finish()
        }
    }
}
